#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>


int main() {
    int n = 0;
    scanf("%d", &n);
    int num = 0;
    int i = 0;
    int max, min;
    int c;
    scanf("%d", &num);
    max = num;
    min = num;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &num);
        if (num > max)
        {
            max = num;
        }
        if (num < min) {
            min = num;
        }
    }
    c = max - min;
    printf("%d\n", c);
    return 0;
}